package com.itheima.polymorphic;

public class Demo2Polymorphic {
    public static void main(String[] args) {
        humanity(new Zi());
        humanity(new Son());
    }
    public static void humanity(Fu fu){
        fu.doSomething();
        if(fu instanceof Son) {
            Son son = (Son) fu;
            son.bad();
        }
        if(fu instanceof Zi){
            Zi zi = (Zi)fu;
            zi.good();
        }
    }
}

interface Fu{
    void doSomething();
}
class Zi implements Fu{

    @Override
    public void doSomething() {
        System.out.println("做个好人");
    }
    public void good(){
        System.out.println("劫富济贫");
    }
}
class Son implements Fu{
    @Override
    public void doSomething() {
        System.out.println("做个坏人");
    }
    public void bad(){
        System.out.println("杀人越货");
    }
}